package ch03;

class OperatorEx22 {
	public static void main(String args[]) {
		 int temp; 

		System.out.println(-8);
		System.out.println(Integer.toBinaryString(-8));	
		System.out.println();			
		
		temp = -8 << 1; // -8*2
		System.out.println( "-8 << 1  = " + temp);
		 // fill in a blank with 0.
		System.out.println(Integer.toBinaryString(temp));
		System.out.println();
		
		temp = -8 << 2; // 8*4
		System.out.println( "-8 << 2  = " + temp);
		System.out.println(Integer.toBinaryString(temp));
		System.out.println();
				
		System.out.println();
		System.out.println(-8);
		System.out.println(Integer.toBinaryString(8));
		System.out.println();
		
		temp = -8 >> 1; // -8/2		
		System.out.println( "-8 >> 1  = " + temp);
		// in minus value, fill in a blank with 1.
		// in plus value, fill in a blank with 0.
		System.out.println(Integer.toBinaryString(temp));
		System.out.println();
		
		temp = -8 >> 2; // -8/4
		System.out.println( "-8 >> 2  = " + temp);
		System.out.println(Integer.toBinaryString(temp));
		System.out.println();
				
		System.out.println();
		System.out.println(-8);
		System.out.println(Integer.toBinaryString(-8));
		System.out.println();
		
		temp = -8 >>> 1;
		System.out.println( "-8 >>> 1  = " + temp); 
		// fill in a blank with 0.		
		System.out.println(Integer.toBinaryString(temp));
		// 01111111111111111111111111111100
		System.out.println();
		
		temp = -8 >>> 2;
		System.out.println( "-8 >>> 2  = " + temp);
		System.out.println(Integer.toBinaryString(temp)); // 00111111111111111111111111111110
		System.out.println();
	}
}
/*
-8
11111111111111111111111111111000

-8 << 1  = -16
11111111111111111111111111110000

-8 << 2  = -32
11111111111111111111111111100000


-8
11111111111111111111111111111000

-8 >> 1  = -4
11111111111111111111111111111100

-8 >> 2  = -2
11111111111111111111111111111110


-8
11111111111111111111111111111000

-8 >>> 1  = 2147483644
1111111111111111111111111111100

-8 >>> 2  = 1073741822
111111111111111111111111111110
*/